package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderedMapper {
    void insert(Orders orders);
    /**
     * 根据订单号和用户id查询订单
     * @param orderNumber
     * @param userId
     */
    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);
    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    List<Orders> pageList(OrdersPageQueryDTO ordersPageQueryDTO);

    Orders getByid(Long id);

    Integer getCountByStatus(Integer status);
    @Select("select * from orders where status = #{status} and order_time < #{now};")
    List<Orders> getStatusAndOrderTime(Integer status, LocalDateTime now);

    BigDecimal sumCondition(Integer status, LocalDate localDate);

    Integer getOrderNow(Map map);

    List<GoodsSalesDTO> selecTop10(LocalDate begin, LocalDate end);
}
